package com.twu.biblioteca;

/**
 * Created with IntelliJ IDEA.
 * User: juliofarah
 * Date: 10/6/13
 * Time: 5:57 PM
 * To change this template use File | Settings | File Templates.
 */
public class User {

    private String name;
    private String email;
    private String phone;
    private String username;
    private int libraryNumber;
    private Boolean loggedIn;
    private String password;

    public User(){
        this.loggedIn = false;
    }

    public User(String username, String password){
        this();
        this.username = username.replaceAll("-", "");
        this.password = password;
    }

    public User(String username, String password, String email, String name, String phone){
        this(username, password);
        this.email = email;
        this.name = name;
        this.phone = phone;
    }

    public String getFormattedUsername() {
        setUsername();
        return username.substring(0,3)+"-"+username.substring(3, username.length());
    }

    public void setUsername(){
        username = String.valueOf(libraryNumber);
    }

    public int getLibraryNumber() {
        return libraryNumber;
    }

    public String getPassword() {
        return password;
    }

    public void setLibraryNumber(int libraryNumber) {
        this.libraryNumber = libraryNumber;
    }

    public Boolean isLoggedIn() {
        return loggedIn;
    }

    public void setLoggedIn(Boolean loggedIn) {
        this.loggedIn = loggedIn;
    }

    public String getUsername(){
        return this.username;
    }

    public String toString(){
        return this.getFormattedUsername() + ", " +
                this.name + ", " +
                this.email + ", " +
                this.phone;
    }
}
